<?php

namespace App\Http\Controllers\Web;

use App\Requests\Api\Users\ClientInfoRequest;
use App\Requests\Api\Users\ListRequest;
use App\Requests\Api\Users\StoreRequest;
use App\Requests\Api\Users\UpdateRequest;
use App\Service\DailyRecordService;
use App\Service\UsersService;
use App\Http\Controllers\Controller;
use http\Env\Request;
use League\Fractal\Manager;
use App\Transformers\Users\UsersTransformer;

class UserController extends Controller
{
    protected $usersService;
    protected $fractal;
    protected $usersTransFormer;
    protected $dailyRecordService;

    public function __construct(
        Manager $fractal,
        UsersService $usersService,
        DailyRecordService $dailyRecordService,
        UsersTransformer $usersTransFormer
    ){
        $this->usersService = $usersService;
        $this->fractal = $fractal;
        $this->usersTransFormer = $usersTransFormer;
        $this->dailyRecordService = $dailyRecordService;
    }

    /**
     * 报名
     * @param StoreRequest $store
     * @return mixed
     */
    public function store(StoreRequest $store) {
        $identity = ['identity_id' => 5];
        $userInfo = $this->usersService->store(array_merge(request(['username', 'gender', 'birthday', 'school_id', 'contacts', 'telephone', 'phone_last_number', 'invitation_code', 'group_photo']),$identity));
        return response($userInfo);
    }

    /**
     * 用户信息
     * @param $userId
     */
    public function info(ClientInfoRequest $clientInfoRequest) {
        $usersInfo = $this->usersService->clientUserDetail(request(['openid']));
        return response($usersInfo);
    }



}
